package com.qf.service.impl;

import com.qf.entity.TbInfoDetail;
import com.qf.dao.TbInfoDetailDao;
import com.qf.service.TbInfoDetailService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TbInfoDetail)表服务实现类
 *
 * @author makejava
 * @since 2021-04-06 09:44:32
 */
@Service("tbInfoDetailService")
public class TbInfoDetailServiceImpl implements TbInfoDetailService {
    @Resource
    private TbInfoDetailDao tbInfoDetailDao;

    /**
     * 通过ID查询单条数据
     *
     * @param infoDetailId 主键
     * @return 实例对象
     */
    @Override
    public TbInfoDetail queryById(Integer infoDetailId) {
        return this.tbInfoDetailDao.queryById(infoDetailId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<TbInfoDetail> queryAllByLimit(int offset, int limit) {
        return this.tbInfoDetailDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tbInfoDetail 实例对象
     * @return 实例对象
     */
    @Override
    public TbInfoDetail insert(TbInfoDetail tbInfoDetail) {
        this.tbInfoDetailDao.insert(tbInfoDetail);
        return tbInfoDetail;
    }

    /**
     * 修改数据
     *
     * @param tbInfoDetail 实例对象
     * @return 实例对象
     */
    @Override
    public TbInfoDetail update(TbInfoDetail tbInfoDetail) {
        this.tbInfoDetailDao.update(tbInfoDetail);
        return this.queryById(tbInfoDetail.getInfoDetailId());
    }

    /**
     * 通过主键删除数据
     *
     * @param infoDetailId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer infoDetailId) {
        return this.tbInfoDetailDao.deleteById(infoDetailId) > 0;
    }

    @Override
    public List<String> queryDetailName(int[] detailIds) {
        return tbInfoDetailDao.queryDetailName(detailIds);
    }
}